package org.slf4j.helpers;

import cc.ifok.kit.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.ObjectStreamException;
import java.io.Serializable;

abstract class NamedLoggerBase implements Logger, Serializable {
    private static final long serialVersionUID = -4925556563480177045L;

    protected String name;
    public String getName() {
        return name;
    }
    protected Object readResolve() throws ObjectStreamException {
        return LoggerFactory.getLogger(getName());
    }

    protected void out(String log, String level) {
        Thread thread = Thread.currentThread();
        StackTraceElement ste = thread.getStackTrace()[3];
        String stringify = String.join("⎥", level,
                                       String.join("→ ", "T", thread.getName()),
                                       String.join("→ ", "C", ste.getClassName()),
                                       String.join("→ ", "F", ste.getMethodName()),
                                       String.join("→ ", "L", Strings.EMPTY + ste.getLineNumber()),
                                       String.join("→ ", "M", log)
        );
        System.out.println(stringify);
    }
}